package com.joizhang.nettylecture.nio;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author joizhang
 */
public class NioTest2 {

    public static void main(String[] args) throws IOException {
        try (FileInputStream fileInputStream = new FileInputStream("NioTest2.txt")) {
            FileChannel fileChannel = fileInputStream.getChannel();
            ByteBuffer byteBuffer = ByteBuffer.allocate(512);
            fileChannel.read(byteBuffer);
            byteBuffer.flip();
            while (byteBuffer.hasRemaining()) {
                System.out.println((char)byteBuffer.get());
            }
        }
    }

}
